Skip to content

Conversation

@niaow
Copy link
Member

@niaow niaow commented Jun 15, 2020

Earlier on slack @aykevl suggested that something like this would be needed.

Usage example with systick:

package main

import (
	"device/arm"
	"machine"
	"runtime"
)

var cond runtime.Cond

func main() {
	machine.LED.Configure(machine.PinConfig{Mode: machine.PinOutput})

	// timer fires 10 times per second
	arm.SetupSystemTimer(machine.CPUFrequency() / 10)

	for {
		machine.LED.Low()
		cond.Wait()
		machine.LED.High()
		cond.Wait()
	}
}

//export SysTick_Handler
func timer_isr() {
	cond.Notify()
}

Current issues making this WIP/not ready:

  1. runtime: make channels work in interrupts #1142 needs to be merged
  2. Where should this go? It was originally in runtime/interrupt, but that caused an import cycle.
  3. The no-scheduler implementation is still suboptimal (it should wait instead of using a polling loop).

@niaow niaow added this to the v0.15 milestone Jun 27, 2020
@niaow
Copy link
Member Author

niaow commented Jul 12, 2020

The no-scheduler implementation is still suboptimal (it should wait instead of using a polling loop).

This part has now been resolved.

@niaow
Copy link
Member Author

niaow commented Jul 12, 2020

Where should this go?

@aykevl any opinion?

@deadprogram
Copy link
Member

Reminder to @aykevl and @niaow about this PR. 😺

@niaow niaow marked this pull request as ready for review September 12, 2020 14:29
@niaow
Copy link
Member Author

niaow commented Sep 12, 2020

This should work decently now. However, my computer isn't recognizing my ARM boards right now so I have not been able to test on hardware.

@deadprogram
Copy link
Member

Tested with the provided example on ATSAMD21 board (Circuit Playground Express) and then also on nrf52840 (Circuit Playground Bluefruit) and both worked exactly as expected.

@aykevl any feedback before this gets merged?

@deadprogram
Copy link
Member

We really need this for something specific. Code looks good, and works as promised, so now merging. Thanks @niaow for this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants